package com.scyshkj.university.wechat.pay;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.scyshkj.university.wechat.utils.JsonDto;
import com.scyshkj.university.wechat.utils.ParameterToMap;
import com.scyshkj.university.wechat.utils.RandomStringUtil;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Date;

/**
 * Created by 唐旭 on 2016/11/21.
 */
@Data
public class RechargeResultDto extends JsonDto implements ParameterToMap {
    private String appid;
    private String timeStamp;
    private String nonceStr;
    @JsonProperty("package")
    private String prepayId;
    private String signType;
    private String paySign;

    public RechargeResultDto() {
        this.state = true;
    }

    public RechargeResultDto(WechatUnifiedOrderResult result) {
        this.state = true;
        this.message = result.getReturn_msg();
        this.prepayId = result.getPrepay_id();
        this.signType = "MD5";
        this.nonceStr = RandomStringUtil.getRandomString(32);
        this.timeStamp = new Date().getTime() + "";
    }

    public RechargeResultDto(String message) {
        this.state = false;
        this.message = message;
    }
}
